//
//  UILabelAttr+Extension.swift
//  CMDB
//
//  Created by 曹桂祥 on 2017/5/22.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

extension UILabel {
    
    internal func setAttr(attr: NSAttributedString?) {
        
        if let attr = attr {
            
            attributedText = attr
        }
    }
    internal func appendAttr(attr: NSAttributedString?) {
        
        
        if let attributedText = attributedText {
            
            let mutable = NSMutableAttributedString(attributedString: attributedText)
            
            if let attr = attr  {
                
                mutable.appendAttributedString(attr)
                
                self.attributedText = mutable
            }
            
        } else {
            
            let mutable = NSMutableAttributedString()
            
            if let attr = attr  {
                
                mutable.appendAttributedString(attr)
                
                self.attributedText = mutable
            }
        }
    }
}
extension UILabel {
    
    func setNormalText(str: String?) {
        
        if let str = str {
            
            text = str
        }
    }
    
    func appendText(str: String?) {
        
        if let text = text {
            
            var mutable = ""
            
            mutable += text
            
            if let str = str {
                
                mutable += str
                
                self.text = mutable
            }
        } else {
            
            var mutable = ""
            
            if let str = str {
                
                mutable += str
                
                self.text = mutable
            }
        }
    }
}


